﻿using Microsoft.AspNetCore.Mvc;
using SX.BaseService.API.Base;
using SX.BaseService.Service.Implement.Microservice.ViewModel;
using SX.BaseService.Service.Interface;
using SX.Core;
using SX.ServiceDiscovery.Abstractions;
using System.ComponentModel;
using System.Threading.Tasks;

namespace SX.BaseService.API.Controllers
{

    [Description("网关配置")]
    [Menu]
    public class ApiGateWayConfController : BaseController
    {
        private readonly IMicroService _service;
        private readonly IServiceDiscovery _serviceDiscovery;
        public ApiGateWayConfController(IMicroService service, IServiceDiscovery serviceDiscovery )
        {
            _service = service;
            _serviceDiscovery = serviceDiscovery;
        }

        [HttpGet]
        [Description("查询网关配置列表")]
        public async Task<IApiResult> QueryApiGatewayConfiguration([FromQuery] GatewayConfigurationQueryModel input)
        {
            return await _service.QueryApiGatewayConfiguration(input);
        }


        [HttpPost]
        [Description("新增网关配置")]
        public async Task<IApiResult> AddApiGatewayConfiguration([FromBody] GatewayConfigurationAddModel input)
        {
            return await _service.AddApiGatewayConfiguration(input);
        }

        [HttpGet]
        [Description("同步网关配置到Consul")]
        public async Task<IApiResult> SyncApiGatewayConfigurationToConsul([FromQuery] string gatewayId)
        {
            return await _service.SyncApiGatewayConfigurationToConsul(gatewayId);
        }

        [HttpGet]
        [Description("同步网关配置到Redis")]
        public async Task<IApiResult> SyncApiGatewayConfigurationToRedis([FromQuery] string gatewayId)
        {
            return await _service.SyncApiGatewayConfigurationToRedis(gatewayId);
        }


    }
}
